﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PlatForm.DataLayer;

namespace PlatForm.Controller
{
    public class PackageController
    {
        public List<Package> GetList()
        {
            return Package.Objects.ToList();
        }

        public int Save(Package package)
        {
            var isNew = 1;
            var s = Package.Objects.FirstOrDefault(x => x.PCK_No == package.PCK_No);
            if (s != null)
            {
                Package.Objects.Delete(x => x.PCK_No == package.PCK_No);
                isNew = 0;
            }
            package.Insert(true);
            return isNew;
        }

        public void Delete(string PCK_No)
        {
            Package.Objects.Delete(x => x.PCK_No == PCK_No);
        }
    }
}
